/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.FlightAdjustSuperfluity;
import com.sasis.dao.FlightAdjustSuperfluityDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class FlightAdjustSuperfluityDaoiBatis extends BaseDaoiBATIS implements FlightAdjustSuperfluityDao {

    /**
     * @see com.sasis.dao.FlightAdjustSuperfluityDao#getFlightAdjustSuperfluitys(com.sasis.model.FlightAdjustSuperfluity)
     */
    public List getFlightAdjustSuperfluitys(final FlightAdjustSuperfluity flightAdjustSuperfluity) {
          return getSqlMapClientTemplate().queryForList("getFlightAdjustSuperfluitys", flightAdjustSuperfluity);
    }

    /**
     * @see com.sasis.dao.FlightAdjustSuperfluityDao#getFlightAdjustSuperfluity(Integer id)
     */
    public FlightAdjustSuperfluity getFlightAdjustSuperfluity(Integer id) {
        FlightAdjustSuperfluity flightAdjustSuperfluity = (FlightAdjustSuperfluity) getSqlMapClientTemplate().queryForObject("getFlightAdjustSuperfluity", id);

        //if (flightAdjustSuperfluity == null) {
            //throw new ObjectRetrievalFailureException(FlightAdjustSuperfluity.class, id);
        //}

        return flightAdjustSuperfluity;
    }

    /**
     * @see com.sasis.dao.FlightAdjustSuperfluityDao#saveFlightAdjustSuperfluity(FlightAdjustSuperfluity flightAdjustSuperfluity)
     */    
    public int saveFlightAdjustSuperfluity(final FlightAdjustSuperfluity flightAdjustSuperfluity) {
        Integer id = flightAdjustSuperfluity.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addFlightAdjustSuperfluity", flightAdjustSuperfluity);
        } else {
            getSqlMapClientTemplate().update("updateFlightAdjustSuperfluity", flightAdjustSuperfluity);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(FlightAdjustSuperfluity.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.FlightAdjustSuperfluityDao#removeFlightAdjustSuperfluity(Integer id)
     */
    public void removeFlightAdjustSuperfluity(FlightAdjustSuperfluity flightAdjustSuperfluity) {
        getSqlMapClientTemplate().update("deleteFlightAdjustSuperfluity",  flightAdjustSuperfluity);
    }
}
